// ***********************************************************
//   CCodeCounter.h - main class handling common features of CodeCount
//
//   REVISION  DATE     AUTHOR				MODIFICATION
//   Rev-1    Fall 07   WHH					Original author, CSSE
//   Rev-2    9/13/08   VN                  Updated ReplaceQuote method
//                                            by adding an overloading ReplaceQuote(...)
//                                          Rewrote CountCommentsSLOC() method
// ***********************************************************

#ifndef CCodeCounter_h
#define CCodeCounter_h

#include "cc_main.h"
#include "CUtil.h"

class CCodeCounter
{
public:

	CCodeCounter();
	virtual ~CCodeCounter();
	virtual void InitializeCounts();

	virtual int CountSLOC(filemap*, results*);
	unsigned int classtype; //Mod042909AS
	bool isSupportedFileExtension(string);
	virtual ofstream* getOutputStream(string outputFileNamePrePend = "");
	virtual void closeOutputStream();

	static size_t FindQuote(string const &strline, string const &QuoteStart, size_t idx_start, char QuoteEscapeFront);

	StringVector  directive;
	StringVector  data_name_list;
	StringVector  exec_name_list;

	StringVector  math_func_list;		// MMG : Defines the list of Math Functions that need to be counted
	StringVector  trig_func_list;
	StringVector  log_func_list;
	StringVector  cmplx_calc_list;
	StringVector  cmplx_cond_list;
	StringVector  cmplx_logic_list;
	StringVector  cmplx_preproc_list;	// MMG : Defines the list of Preprocessor Directives that need to be counted for complexity 
	StringVector  cmplx_assign_list;
	StringVector  cmplx_pointer_list;	// RST

	IntPairVector directive_count;
	IntPairVector data_name_count;
	IntPairVector exec_name_count;

	IntPairVector math_func_count;		// MMG
	IntPairVector trig_func_count;
	IntPairVector log_func_count;
	IntPairVector cmplx_calc_count;
	IntPairVector cmplx_cond_count;
	IntPairVector cmplx_logic_count;
	IntPairVector cmplx_preproc_count;
	IntPairVector cmplx_assign_count;	// End MMG
	IntPairVector cmplx_pointer_count;	// RST

	bool          isPrintKeyword;
	string        language_name;
	unsigned int  total_filesA;
	unsigned int  total_filesB;

protected:

	StringVector  file_extension;
	StringVector  flow_control_keywords;

	string QuoteStart;		// if language supports multiple quote marks such as javascript,
	string QuoteEnd;		// you can put all of them here, ex. "\"'"

	char QuoteEscapeFront;  //ex. \" in C++, then put '\' here
	char QuoteEscapeRear;	//ex. "" in VB, then put '"' here
	char ContinueLine;
	StringVector BlockCommentStart;
	StringVector BlockCommentEnd;
	StringVector LineCommentStart;

	bool casesensitive;		//VN: added to specify whether the language is casesensitive or not.

	ofstream output_file;

	virtual int ReplaceQuote(string &strline, size_t &idx_start, bool &contd, char &CurrentQuoteEnd);
	int FindCommentStart(string strline, size_t &idx_start, int &comment_type,
		string &curBlckCmtStart, string &curBlckCmtEnd);
	virtual int CountCommentsSLOC (filemap* fmap, results* result, filemap* fmapBak=NULL);

	int CountBlankSLOC(filemap*,results*);

	virtual int CountComplexity(filemap*, results*);	//AMB: Added Complexity Count function
	virtual int CountDirectiveSLOC(filemap*,results*,filemap* fmapBak=NULL){return 0;}

	virtual int LanguageSpecificProcess(filemap*, results*, filemap* fmapBak=NULL);
};

#endif
